#include <iostream>
using namespace std;

int main(){
        vector<vector<string>> paths;
        paths = {{"B","C"},{"D","B"},{"C","A"}};
        queue<string> q;
        map<string,vector<string>> g;
        map<string,bool> vis;
        for(auto pa : paths){
            g[pa[0]].push_back(pa[1]);
            vis[pa[0]] = false;
            vis[pa[1]] = false;
        }
        string fn = paths[0][0];
        q.push(fn);
        
        while(!q.empty()){
            fn = q.front();
            q.pop();
            if(!vis[fn]){
                q.push(fn);
                vis[fn] = true;
            }
        } 
        cout << fn;
}